﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Krist_em_up.Characters;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;

namespace Krist_em_up.Item.Projectiles
{
    class GunBullet : Projectile
    {

        public GunBullet(int shooter, Kristemup k, Vector2 position, Vector2 direction)
            : base(shooter, k, position, direction)
        {
            texture = k.Content.Load<Texture2D>("bullet2");
            lifeTime = new TimeSpan(0, 0, 0, 3, 0);
            if (shooter >=0)
                speed = new Vector2(15, 1);
            else
                speed = new Vector2(5, 1);
        }

        public override void Update(GameTime gameTime)
        {
            position += speed * direction;
            origin = new Vector2(texture.Width / 2, texture.Height / 2);
            base.Update(gameTime);
        }

        public override void Draw(GameTime gameTime,Vector2 originG)
        {
            SpriteEffects effect = direction.X <= -1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None;
            
            spriteBatch.Begin();
            spriteBatch.Draw(texture, new Rectangle((int)(position.X - origin.X - originG.X), (int)(position.Y - origin.Y - originG.Y), texture.Width, texture.Height),
                null, Color.White, angle, origin, effect, 0f);
            spriteBatch.End();
        }
    }
}
